package com.adinnet.api.information.service.impl;

import com.adinnet.api.information.model.Information;
import com.adinnet.api.information.mapper.InformationMapper;
import com.adinnet.api.information.service.InformationService;
import com.adinnet.core.PageParam;
import com.adinnet.core.PageResp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资讯管理 服务实现类
 * </p>
 *
 * @author chenjia
 * @since 2020-12-03
 */
@Service
public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements InformationService {

    @Override
    public PageResp queryList(PageParam page) {
        Page<Information> informationPage = new Page<>(page.getPage(), page.getLimit());
        QueryWrapper<Information> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", 1).eq("deleted",0).orderByDesc("updated_date");
        IPage<Information> iPage = baseMapper.selectPage(informationPage, queryWrapper);
        return new PageResp<>(iPage.getRecords(), iPage.getTotal());
    }
}
